/**
 * *****************************************************************
 * @file    adt3102_rtc.h
 * @author  WuHao(hwu@andartechs.com.cn)
 * @version 1.0.0
 * @date    2020-11-09
 * @brief   
 *                 Copyright (c) 2020, Andar Technologies Inc.
 *                           www.andartechs.com 
 *
 * *****************************************************************
 */
#ifndef __RTC__H
#define __RTC__H

/*------------------------------ include ------------------------------------*/
#include "adt3102_type_define.h"


/*------------------------------- define -------------------------------------*/
/*
RCSOR : 32k RC
XOSOR : 32k XO
DIVHIGHSOR: div from clk_high, this is for normal function
*/
#define RCSOR      0
#define XOSOR      1
#define DIVHIGHSOR 2


/*------------------------------ function ------------------------------------*/
/**
 * @brief   RTC init.
 * @param   enable: if set to 1,the RTC is enabled,don't write to this bit otherwise the current
 *                RTC value is reset to zero.
 * @param   reloadValue: The reloadValue is compared with the counter value generate an interrupt.
 * @param   rtcClock: Actually the clock frequency generated by 32K clock source, the uint is KHz.
 * @param   clkSource: select clk_32k source. Normally,
 *                  2'h0:32k RC.               -> RCSOR
 *                  2'h1:32k XO.               -> XOSOR
 *                  2'h2: div from clk_high    -> DIVHIGHSOR
 *                  , this is for normal function..
 * @return  function call example:  rtcInit(1, 1000, 32, RCSOR);.
 * @note
 */
void rtcInit(int32 enable, int32 reloadValue,int32 rtcClock,int32 clkSource);

/**
 * @brief   start rtc timer.
 * @param   cycle_number: rtcClock*reloadValue.
 * @return  None.
 * @note
 */
void rtcTimerStart(uint32 cycle_number);
#endif
